package com.qiantu.phone.utils;

import android.content.Context;
import android.content.res.AssetManager;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by huanghaojie on 2016/10/19.
 * 对地址库的增删改查
 */

public class AddressDataUtil {
    private static String addressJsonDataStr;

    public String getAddressJson(Context context) {
        if(addressJsonDataStr != null) {
            return addressJsonDataStr;
        }
        StringBuilder stringBuilder = new StringBuilder();
        try {
            AssetManager assetManager = context.getAssets();
            BufferedReader bf = new BufferedReader(new InputStreamReader(
                    assetManager.open("CityTree.json")));
            String line;
            while ((line = bf.readLine()) != null) {
                stringBuilder.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        addressJsonDataStr = stringBuilder.toString();
        return addressJsonDataStr;
    }
}
